cmake_minimum_required(VERSION 3.10)
project(LibDemo C)

# 创建动态库（关键区别：SHARED）
add_library(math_utils_shared SHARED src/math_utils.c)
#创建静态库
add_library(math_utils_static STATIC src/math_utils.c)

option(LINK_STATIC_MATH_UTILS "Link to static math_utils library" ON)

add_executable(my_app src/main.c)

if(LINK_STATIC_MATH_UTILS)
    target_link_libraries(my_app PRIVATE math_utils_static)
else()
    target_link_libraries(my_app PRIVATE math_utils_shared)
endif()